Ext.define('Admin.view.widgets.EchartBMap', {
	        extend : 'Admin.echarts.Base',
	        xtype : 'echartBMap',

	        echartsPaint : function(view) {
		        var custom = view.custom, option = Ext.apply(Ext.clone(view.option), custom), value = view.value;
		        if (value) {
			        value.title && Ext.apply(option.title, value.title);
			        value.bmap && Ext.apply(option.bmap, value.bmap);
			        var map = new Map();
			        value.series.map(function(serie) {
				                map.set(serie.name, serie.data);
			                });

			        option.series.map(function(serie) {
				                var data = map.get(serie.name);
				                data && Ext.apply(serie.data, data);
			                });

			        view.options = option;
			        view.echartsRefresh(view);
		        }
	        },

	        echartsRefresh : function(view) {
		        if (view.options) {
			        view.echart && echarts.dispose(view.echart); // 先释放，再创建
			        var chart = echarts.init(Ext.fly(view.getId()).dom);
			        chart.setOption(view.options);
			        view.echart = chart;
		        }
	        },

	        updateValue : function(value) {
		        var me = this;
		        if (me.options) {
			        for (var i = 0; i < value.series.length; i += 1) {
				        var data = value.series[i]; // i=0 离线终端,i=1告警,i=2 其他正常终端,i=3线路坐标
				        Ext.apply(me.options.series[i], value.series[i]);
			        }
			        me.echart.setOption(me.options);
		        } else {
			        me.value = value;
			        me.echartsPaint(me);
		        }
	        },

	        option : {
		        title : {},
		        tooltip : {
			        trigger : 'item',
			        // triggerOn : 'click',
			        triggerOn : 'mousemove',
			        formatter : function(params, ticket, callback) {
				        var url;
				        if (params.data.value[2] === 'Saler') {
					        url = 'rest/rpt/bmap/saler/' + params.data.value[3] + '/tooltips';
				        } else {
					        url = 'rest/rpt/bmap/customer/' + params.data.value[3] + '/tooltips';
				        }
				        Admin.Ajax.request({
					                url : url,
					                fnSuccess : function(options, result) {
						                callback(ticket, result.data);
					                }
				                });
				        return '加载中...';
			        }
		        },
		        bmap : {
			        center : [116.403299, 39.981266],
			        zoom : 12,
			        roam : true,
			        mapStyle : {
				        styleJson : [{
					                "featureType" : "poi",
					                "elementType" : "all",
					                "stylers" : {
						                "visibility" : "off"
					                }
				                }, {
					                'featureType' : 'railway',
					                'elementType' : 'all',
					                'stylers' : {
						                'visibility' : 'off'
					                }
				                }, {
					                'featureType' : 'highway',
					                'elementType' : 'all',
					                'stylers' : {
						                'visibility' : 'off'
					                }
				                }, {
					                "featureType" : "subway",
					                "elementType" : "all",
					                "stylers" : {
						                "visibility" : "off"
					                }
				                }]
			        }
		        },
		        series : [{
			                name : 'normal',
			                type : 'scatter',
			                coordinateSystem : 'bmap',
			                data : [],
			                symbolSize : 30,
			                symbol : 'pin',
			                itemStyle : {
				                normal : {
					                color : 'red'
				                }
			                },
			                label : {
				                normal : {
					                show : true,
					                formatter : function(params) {
						                var name = params.data.value[4];
						                return name ? name : '';
					                },
					                position : 'right',
					                textStyle : {
						                color : 'blue',
						                fontWeight : 'bold',
						                fontSize : 16
					                }
				                }
			                }
		                }]
	        }
        });